require 'erb'
require 'common/base'

class IMAPBase < Base

  attr_accessor :step, :transport, :base_options, :base_transports, :base_variables, :message, :user

  def initialize(step, filename, params = {}, transport="IMAP")
    super()
    @transport = transport
    @step = step
    @user = params["user"] or ""
    @mailbox = params["mailbox"] or ""

    @base_options = "
      $user='<%= @user %>'
      $mailbox='<%= @mailbox %>'"

    @base_variables = ''

    @base_transports = 'IMAP = tcp(dst_port: 143)'

    if !filename.nil?
      template = get_message("IMAP", filename)
      erb = ERB.new(template, 0, '%<>')
      @message = erb.result(binding)
    end
  end
end
